#ifndef __SPECTRAL_DIV_H
#define __SPECTRAL_DIV_H

#include "../modularity_mat/modularity_mat.h"
#include "../sparse_mlpl/sparse_matrix.h"

#ifndef __STD_INCLUDES
#define __STD_INCLUDES
#include <stdio.h>
#include <stdlib.h>
#endif /*__STD_INCLUDES*/

#ifndef __MATH_H
#define __MATH_H
#include <math.h>
#endif /*__MATH_H*/

#include <time.h>

#define MAX_ITTERATION 10000000

int calcLeadingEigenPair(sparse_matrix_lst *Ag, elem** GnrModMat, int *K_g, elem *F_g, int M, elem precision, elem **u1, elem *b1);
elem calcVectorNorm(elem *v, int iVectorSize);
int getNormalizedVector(elem *v, int iVectorSize, elem **result);
int getNormalizedIntVector(int *v, int iVectorsize, elem **result);
int normalizeVector(elem *v, int iVectorSize);
elem calcDotProduct(elem *v1, elem *v2, int iVectorSize);
elem calcDotProductIntWithElem(int *v1, elem *v2, int iVectorSize);
elem calcDotProductIntWithInt(int *v1, int *v2, int iVectorSize);
elem calcNormalMatrixOneNorm(elem **A, int n);
int multDiagonalMatWithIntVector(elem *Dii, int *V, int n, elem **product_ptr);
int multDiagonalMatWithVector(elem *Dii, elem *V, int n, elem **product_ptr);
int mulVectorByScalar(elem *v_ptr, elem dScalar, int n, elem **result);
int mulIntVectorByScalar(int *v, elem dScalar, int n, elem **result);
int addTwoVectors(elem *v1, elem *v2, int n, elem **result);
int subV2FromV1(elem *v1, elem *v2, int n, elem **result);
int allocateVector(elem **v, int n);
int allocateIntVector(int **v, int n);
int fastPowerMethod(sparse_matrix_lst *Ag, elem **GnrModMat, int *K_g, elem *F_g, int M, elem precision, elem *X, elem dGnrModMatNorm, elem **result);
int checkApproximation(elem *Xm, elem *XmP1,elem  precision, elem dEigenValue, int n, int *result);
int calcDeltaQ(sparse_matrix_lst *Ag, elem **GnrModMat, int *K_g, elem *F_g, int M, elem *S, elem *result);
int createVertexGroupFromFile(char *sPath, int *pGroupSize, int **pGroup, int n);
int spectralDivideGroup(int iGroupSize, elem *u1, elem b1, sparse_matrix_lst *Ag, elem **GnrModMat, int *Kg,
						elem *Fg, int M, elem *deltaQ, elem *S);
void freeSafely(void* _Memory);

#endif /*__SPECTRAL_DIV_H*/
